package com.briup.jz.web.controller;

import com.briup.jz.bean.OrderComment;
import com.briup.jz.service.IOrderCommentService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/ordercomment")
@Api(description="订单评论管理")
public class OrderCommentController {
    @Autowired
    private IOrderCommentService iOrderCommentService;
    @PostMapping("/submit")
    @ApiOperation("评论订单")
    public Message saveorupdate(OrderComment orderComment){
        iOrderCommentService.saveOrUpdate(orderComment);
        return MessageUtil.success("操作成功");
    }
    @GetMapping("/query")
    @ApiOperation("查询订单")
    @ApiImplicitParam(name = "id" ,value = "顾客id", paramType = "query")
    public  Message query(Long id){
        List<OrderComment> orderComments =iOrderCommentService.query(id);
        return MessageUtil.success(orderComments);
    }
    @GetMapping("/delete")
    @ApiOperation("删除评论")
    @ApiImplicitParam(name = "id" ,value = "评论id", paramType = "query",required = true)

    public Message delete(Long id){
        iOrderCommentService.deleteByid(id);
        return MessageUtil.success("操作成功");
    }
    @ApiOperation("审核不通过")
    @GetMapping("chenckNoPass")
    @ApiImplicitParam(name = "id" ,value = "评论id", paramType = "query",required = true)

    public Message  chenckNoPass(Long id) {
        iOrderCommentService.checkNoPass(id);
        return MessageUtil.success("操作成功");
    }



    @ApiOperation("审核通过")
    @GetMapping("chenckPass")
    @ApiImplicitParam(name = "id" ,value = "评论id", paramType = "query",required = true)
    public Message  chenckPass(Long id) {
        iOrderCommentService.checkPass(id);
        return MessageUtil.success("操作成功");
    }

}




